#include "prec.h"
#include "app.h"
#include "mainpage.h"
#include "imagefactory.h"

MainPage::MainPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) 
: ArtPanel( parent, id, ImageFactory::GetBitmap(wxT("main_bg.png"), wxBITMAP_TYPE_PNG), pos, size, style, ArtPanel::BITMAP_STRETCH )
{
	wxBoxSizer* bSizer58;
	bSizer58 = new wxBoxSizer( wxVERTICAL );

	m_panel12 = new ArtPanel( this, wxID_ANY, ImageFactory::GetBitmap(wxT("titlebar_bg.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, ArtPanel::BITMAP_STRETCH);
	wxBoxSizer* bSizer59;
	bSizer59 = new wxBoxSizer( wxHORIZONTAL );

	m_btnMainPage = new ArtBitmapButton( m_panel12, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("main_btn.png"), wxBITMAP_TYPE_PNG), 
		ImageFactory::GetBitmap(wxT("main_btn_hover.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	bSizer59->Add( m_btnMainPage, 0, wxALL, 5 );

	m_stTitle = new ArtStaticText( m_panel12, wxID_ANY, _("Main Page"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_stTitle->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	bSizer59->Add( m_stTitle, 0, wxALL|wxALIGN_BOTTOM, 5 );


	bSizer59->Add( 0, 0, 1, wxEXPAND, 5 );

	m_btnTime = new ArtButton( m_panel12, wxID_ANY, wxT("MyButton"), wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
	m_btnTime->SetBackground(ImageFactory::GetBitmap(wxT("btn1_bg.png"), wxBITMAP_TYPE_PNG));
	m_btnTime->SetBackgroundHover(ImageFactory::GetBitmap(wxT("btn1_active.png"), wxBITMAP_TYPE_PNG));
	bSizer59->Add( m_btnTime, 0, wxALL, 5 );


	m_panel12->SetSizer( bSizer59 );
	m_panel12->Layout();
	bSizer59->Fit( m_panel12 );
	bSizer58->Add( m_panel12, 0, wxEXPAND, 5 );


	bSizer58->Add( 0, 0, 1, wxEXPAND, 5 );

	wxFlexGridSizer* fgSizer2;
	fgSizer2 = new wxFlexGridSizer( 0, 3, 0, 25 );
	fgSizer2->SetFlexibleDirection( wxBOTH );
	fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

	m_btnMonitorPage = new ArtBitmapButton( this, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("monitor_btn.png"), wxBITMAP_TYPE_PNG),
		ImageFactory::GetBitmap(wxT("monitor_btn_active.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, 0 );
	fgSizer2->Add( m_btnMonitorPage, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	m_btnReservationPage = new ArtBitmapButton( this, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("reservation_btn.png"), wxBITMAP_TYPE_PNG),
		ImageFactory::GetBitmap(wxT("reservation_btn_active.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, 0 );
	fgSizer2->Add( m_btnReservationPage, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	m_btnProgramPage = new ArtBitmapButton( this, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("program_btn.png"), wxBITMAP_TYPE_PNG),
		ImageFactory::GetBitmap(wxT("program_btn_active.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, 0 );
	fgSizer2->Add( m_btnProgramPage, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	ArtStaticText* m_staticText62;
	m_staticText62 = new ArtStaticText( this, wxID_ANY, _("Monitor Page"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_staticText62->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	fgSizer2->Add( m_staticText62, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	ArtStaticText* m_staticText63;
	m_staticText63 = new ArtStaticText( this, wxID_ANY, _("Reservation Page"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_staticText63->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	fgSizer2->Add( m_staticText63, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	ArtStaticText* m_staticText64;
	m_staticText64 = new ArtStaticText( this, wxID_ANY, _("Program Page"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_staticText64->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	fgSizer2->Add( m_staticText64, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

 	m_btnOperationSetting = new ArtBitmapButton( this, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("operation_setting_btn.png"), wxBITMAP_TYPE_PNG),
 		ImageFactory::GetBitmap(wxT("operation_setting_btn_active.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer2->Add( m_btnOperationSetting, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
 
 	m_btnPlotPage = new ArtBitmapButton( this, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("plot_btn.png"), wxBITMAP_TYPE_PNG),
 		ImageFactory::GetBitmap(wxT("plot_btn_active.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer2->Add( m_btnPlotPage, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
 
 	m_btnPageSetting = new ArtBitmapButton( this, wxID_ANY, wxEmptyString, ImageFactory::GetBitmap(wxT("page_setting_btn.png"), wxBITMAP_TYPE_PNG),
 		ImageFactory::GetBitmap(wxT("page_setting_btn_active.png"), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, 0 );
 	fgSizer2->Add( m_btnPageSetting, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	ArtStaticText* m_staticText65;
	m_staticText65 = new ArtStaticText( this, wxID_ANY, _("Operation Setting"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_staticText65->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	fgSizer2->Add( m_staticText65, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	ArtStaticText* m_staticText66;
	m_staticText66 = new ArtStaticText( this, wxID_ANY, _("Plot Page"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_staticText66->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	fgSizer2->Add( m_staticText66, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );

	ArtStaticText* m_staticText67;
	m_staticText67 = new ArtStaticText( this, wxID_ANY, _("Page Setting"), wxDefaultPosition, wxDefaultSize, wxNO_BORDER );
	m_staticText67->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxEmptyString ) );

	fgSizer2->Add( m_staticText67, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );


	bSizer58->Add( fgSizer2, 0, wxALIGN_CENTER_HORIZONTAL, 5 );


	bSizer58->Add( 0, 0, 1, wxEXPAND, 5 );


	this->SetSizer( bSizer58 );
	this->Layout();

	// Connect Events
 	m_btnMainPage->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnMainPage ), NULL, this );
 	m_btnTime->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnTime ), NULL, this );
 	m_btnMonitorPage->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnMonitorPage ), NULL, this );
 	m_btnReservationPage->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnReservationPage ), NULL, this );
 	m_btnProgramPage->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnProgramPage ), NULL, this );
 	m_btnOperationSetting->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnOperationSetting ), NULL, this );
 	m_btnPlotPage->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnPlotPage ), NULL, this );
 	m_btnPageSetting->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnPageSetting ), NULL, this );

	UpdateTime();
}

MainPage::~MainPage()
{
	// Disconnect Events
 	m_btnMainPage->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnMainPage ), NULL, this );
 	m_btnTime->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnTime ), NULL, this );
 	m_btnMonitorPage->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnMonitorPage ), NULL, this );
 	m_btnReservationPage->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnReservationPage ), NULL, this );
 	m_btnProgramPage->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnProgramPage ), NULL, this );
 	m_btnOperationSetting->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnOperationSetting ), NULL, this );
 	m_btnPlotPage->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnPlotPage ), NULL, this );
 	m_btnPageSetting->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainPage::OnBtnPageSetting ), NULL, this );

}

void MainPage::OnBtnMainPage( wxCommandEvent& event )
{

}

void MainPage::OnBtnTime( wxCommandEvent& event )
{

}

void MainPage::OnBtnMonitorPage( wxCommandEvent& event )
{

}

void MainPage::OnBtnReservationPage( wxCommandEvent& event )
{

}

void MainPage::OnBtnProgramPage( wxCommandEvent& event )
{

}

void MainPage::OnBtnOperationSetting( wxCommandEvent& event )
{

}

void MainPage::OnBtnPlotPage( wxCommandEvent& event )
{

}

void MainPage::OnBtnPageSetting( wxCommandEvent& event )
{

}

void MainPage::UpdateTime( const wxDateTime& dt )
{
	wxString date = dt.Format(wxT("%Y-%m-%d"));
	wxString time = dt.FormatTime();

	m_btnTime->SetLabel(date + wxT("\n") + time);
}